using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ContentPanel : MonoBehaviour
{

    private string Ip = "192.168.10.101";

    public Toggle tg101;
    public Toggle tg102;
    public Toggle tg103;

    public GameObject playPanel;
    public GameObject twoPanel;

    public GameObject shouYePanel;
    public Button yuanBtn;
    public Button g_Btn;
    public Button backBtn;
    private bool isTwo = false;


    void Start()
    {
        tg101.onValueChanged.AddListener((isOn) => {
            if (isOn)
            {
                playPanel.SetActive(true);
                twoPanel.SetActive(false);
                SetIp(tg101.name);
                PlayerControl.SetIp(Ip);
                PlayerControl.GetFiles();
            }
        });
        tg102.onValueChanged.AddListener((isOn) => {
            if (isOn)
            {
                playPanel.SetActive(false);
                twoPanel.SetActive(true);               
            }
        });
        tg103.onValueChanged.AddListener((isOn) => {
            if (isOn)
            {
                playPanel.SetActive(true);
                twoPanel.SetActive(false);
                SetIp(tg103.name);
                PlayerControl.SetIp(Ip);
                PlayerControl.GetFiles();
            }
        });

        yuanBtn.onClick.AddListener(() => {
            playPanel.SetActive(true);
            twoPanel.SetActive(false);
            SetIp(tg102.name);
            PlayerControl.SetIp(Ip);
            PlayerControl.GetFiles();

            isTwo = true;
        });
        backBtn.onClick.AddListener(() => {
            if (isTwo)
            {
                isTwo = false;
                playPanel.SetActive(false);
                twoPanel.SetActive(true);
            }
            else
            {
                this.gameObject.SetActive(false);
                shouYePanel.SetActive(true);
            }
        });

        SetIp(tg101.name);
        PlayerControl.SetIp(Ip);
        PlayerControl.GetFiles();

    }

    private void SetIp(string end)
    {
        Ip = "192.168.10." + end.Trim();
    }
    void Update()
    {
        
    }
}
